home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
mcomm
/
zcmplr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-02
|
13KB
|
370 lines
/*/////////////////////////////////////////////////////////////////////
// //
// //
// ZCMPLR.C -- compiler specific functions //
// //
// (c) 1991, Mike Dumdei, 6 Holly Lane, Texarkana TX, 75503 //
// //
//////////////////////////////////////////////////////////////////// */
#ifndef __TURBOC__ /* defined by Turbo C compiler */
#ifndef __ZTC__ /* defined by Zortech C compiler */
#define __MSC__ /* assume Microsoft C if not TC or ZTC */
#endif
#endif
extern long PrevHunds;
extern long PrevSecs;
/*/////////////////////////////////////////////////////////////////
// //
// //
// Microsoft C / Quick C //
// //
// //
//////////////////////////////////////////////////////////////// */
#ifdef __MSC__
#include <dos.h>
/*/////////////////////////////////////////////////////////
// DosFindFirst -- find file (1st instance) //
//////////////////////////////////////////////////:disk:/*/
int DosFindFirst(char *pathname, int atrib, struct find_t *fstruc)
{
return (_dos_findfirst(pathname, atrib, fstruc));
}
/*/////////////////////////////////////////////////////////
// DosFindNext -- find file (except 1st instance) //
//////////////////////////////////////////////////:disk:/*/
int DosFindNext(struct find_t *fstruc)
{
return (_dos_findnext(fstruc));
}
/*/////////////////////////////////////////////////////////
// DosGetDiskFree -- gets free space left on disk //
//////////////////////////////////////////////////:disk:/*/
long DosGetDiskFree(int drive)
{
struct diskfree_t spc;
_dos_getdiskfree(drive, &spc);
return ((long)spc.avail_clusters * (long)spc.sectors_per_cluster *
(long)spc.bytes_per_sector);
}
/*/////////////////////////////////////////////////////////
// DosSetFileTime -- set file date/time //
//////////////////////////////////////////////////:disk:/*/
int DosSetFileTime(int handle, unsigned date, unsigned time)
{
return (_dos_setftime(handle, date, time));
}
/*/////////////////////////////////////////////////////////
// DosSetFileAttr -- set file attribute //
//////////////////////////////////////////////////:disk:/*/
int DosSetFileAttr(char *path, unsigned attrib)
{
return (_dos_setfileattr(path, attrib));
}
/*/////////////////////////////////////////////////////////
// getHunds -- get time to 1/100 of a second //
//////////////////////////////////////////////////:time:/*/
long getHunds(void)
{
struct dostime_t hmsh;
long hunds;
_dos_gettime(&hmsh);
hunds = (((((long)hmsh.hour * 60L + (long)hmsh.minute) * 60L)
+ (long)hmsh.second) * 100L) + (long)hmsh.hsecond;
while (hunds < PrevHunds)
hunds += (24L * 60L * 60L * 100L);
PrevHunds = hunds;
return (hunds);
}
/*/////////////////////////////////////////////////////////
// getSeconds -- get time to nearest second //
//////////////////////////////////////////////////:time:/*/
long getSeconds(void)
{
struct dostime_t hmsh;
long secs;
_dos_gettime(&hmsh);
secs = (((long)hmsh.hour * 60L + (long)hmsh.minute) * 60L) +
(long)hmsh.second;
while (secs < PrevSecs)
secs += (24L * 60L * 60L);
PrevSecs = secs;
return (secs);
}
#endif
/*/////////////////////////////////////////////////////////////////
// //
// //
// Turbo C / Turbo C++ //
// //
// //
//////////////////////////////////////////////////////////////// */
#ifdef __TURBOC__
#include <dos.h>
#include <dir.h>
#include <io.h>
#if __TURBOC__ >= 0x0410
#include <bios.h>
#else
/*/////////////////////////////////////////////////////////
// _bios_keybrd -- link to Turbo C/C++ bios key //
/////////////////////////////////////////////////////////*/
int _bios_keybrd(int flag)
{
return bioskey(flag);
}
#endif
/*/////////////////////////////////////////////////////////
// DosFindFirst -- find file (1st instance) //
//////////////////////////////////////////////////:disk:/*/
int DosFindFirst(char *pathname, int atrib, struct ffblk *fstruc)
{
return (findfirst(pathname, fstruc, atrib));
}
/*/////////////////////////////////////////////////////////
// DosFindNext -- find file (except 1st instance) //
//////////////////////////////////////////////////:disk:/*/
int DosFindNext(struct ffblk *fstruc)
{
return (findnext(fstruc));
}
/*/////////////////////////////////////////////////////////
// DosGetDiskFree -- gets free space left on disk //
//////////////////////////////////////////////////:disk:/*/
long DosGetDiskFree(int drive)
{
struct dfree spc;
getdfree(drive, &spc);
return ((long)spc.df_avail * (long)spc.df_sclus * (long)spc.df_bsec);
}
/*/////////////////////////////////////////////////////////
// getHunds -- get time to 1/100 of a second //
//////////////////////////////////////////////////:time:/*/
long getHunds(void)
{
struct time hmsh;
long hunds;
gettime(&hmsh);
hunds = (((((long)hmsh.ti_hour * 60L + (long)hmsh.ti_min) * 60L)
+ (long)hmsh.ti_sec) * 100L) + (long)hmsh.ti_hund;
while (hunds < PrevHunds)
hunds += (24L * 60L * 60L * 100L);
PrevHunds = hunds;
return (hunds);
}
/*/////////////////////////////////////////////////////////
// getSeconds -- get time to nearest second //
//////////////////////////////////////////////////:time:/*/
long getSeconds(void)
{
struct time hmsh;
long secs;
gettime(&hmsh);
secs = (((long)hmsh.ti_hour * 60L + (long)hmsh.ti_min) * 60L)
+ (long)hmsh.ti_sec;
while (secs < PrevSecs)
secs += (24L * 60L * 60L);
PrevSecs = secs;
return (secs);
}
/*/////////////////////////////////////////////////////////
// DosSetFileTime -- set file date/time //
//////////////////////////////////////////////////:disk:/*/
int DosSetFileTime(int handle, unsigned date, unsigned time)
{
unsigned long ftim = ((unsigned long)date << 16) | (unsigned long)time;
return (setftime(handle, (struct ftime *)&ftim));
}
/*/////////////////////////////////////////////////////////
// DosSetFileAttr -- set file attribute //
// //
// Older versions of TURBO C libraries (TC++ 1.00 for //
// sure) do not have the _dos_setfileattr function so //
// the call to it is #if'd out. The defined version //
// (0x0400) corresponds to BC++ 3.0 which does have the //
// _dos_setfileattr function. Probably some versions //
// earlier than 4.0 do too but didn't have them to find //
// out. It is only used if an undocumented switch is //
// enabled so you probably will never miss it. //
//////////////////////////////////////////////////:disk:/*/
int DosSetFileAttr(char *path, unsigned attrib)
{
#if __TURBOC__ >= 0x0400
return (_dos_setfileattr(path, attrib));
#else
return 0;
#endif
}
#endif
/*/////////////////////////////////////////////////////////////////
// //
//